<%--
  Created by IntelliJ IDEA.
  User: zll
  Date: 2018/5/30
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>

    <jsp:include page="../comm/comm.jsp"/>
</head>
<body>
<div class="layui-form" action="">

        <div class="layui-input-inline" style="width: 100px;">
            <button class="layui-btn layui-btn-warm" id="add">添加</button>
        </div>
    </div>
</div>
<table id="demo" lay-filter="test"></table>


<script type="text/html" id="operate">
    <button class="layui-btn layui-btn-sm" onclick="modify('{{d.id}}')">修改</button>
    <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="deletes('{{d.id}}')">删除</button>
</script>


<script>
    function modify(id){
         location.href="/tasks/modify?id="+id
    }
    function deletes(id){
        //eg1
        layer.confirm('确认删除?', {icon: 3, title:'提示'}, function(index){
            config.commPost("/tasks/delete.json",{id:id},function (data) {
                alert("成功");
                location.reload();
            })

            layer.close(index);
        });
    }
    layui.use('table', function(){

        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            ,url: '/role/getTask?type=1' //数据接口
            ,page: true //开启分页
            ,limits:[10]
            ,response: {
                statusName: 'status' //数据状态的字段名称，默认：code
                ,statusCode: 200 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'msg' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            }
            ,cols: [[ //表头
                {field: 'name', title: '姓名'},
                {field: 'content', title: '内容'},
                {field: 'createrTime', title: '时间',templet: '#date'},
                {field: 'createTime', title: '操作',templet: '#operate'},
            ]]
        });
        $("#add").click(function () {
            location.href="/page/dzhd/updz";
        });
    });
</script>
</body>
</html>
